package com.homework.exam02.Test;/*
 *@Author: helen
 *@Date:   2021/4/17 21:13
 *@Description:
 */

import com.homework.exam02.Event.NoticeEvent;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.event.ApplicationEventMulticaster;

@SpringBootTest
public class Exam02Tests {

    @Autowired
    ApplicationEventMulticaster eventMulticaster;

    /**
     * 测试使用线程池异步发布事件
     * 观察终端打印信息，并确认打印信息的线程名称
     */
    @Test
    void testAsyncEventMulticaster() throws InterruptedException {
        eventMulticaster.multicastEvent(new NoticeEvent("东莞理工学院"));
        eventMulticaster.multicastEvent(new NoticeEvent("网安学院"));
        Thread.sleep(2100);
    }

}
